use crate::{process_gen_pass, CmdExecutor};
use clap::Parser;

#[derive(Debug, Parser)]
pub struct GenPassOpts {
    #[arg(short, long, default_value_t = 16)]
    pub length: usize,
    #[arg(long, default_value_t = true)]
    pub upper: bool,
    #[arg(long, default_value_t = true)]
    pub lower: bool,
    #[arg(long, default_value_t = true)]
    pub number: bool,
    #[arg(long, default_value_t = true)]
    pub symbol: bool,
}

impl CmdExecutor for GenPassOpts {
    async fn execute(self) -> anyhow::Result<()> {
        let password = process_gen_pass(
            self.length,
            self.upper,
            self.lower,
            self.number,
            self.symbol,
        );
        println!("{}", password);
        //输出密码强度到终端，使用zxcvbn检查密码强度
        eprintln!(
            "Password Strength:{}",
            zxcvbn::zxcvbn(password.as_str(), &[]).unwrap().score()
        );
        Ok(())
    }
}
